package com.xayy.mgt.model;

import cn.kawins.mybatis.base.BaseModel;
import cn.kawins.mybatis.interceptor.FillingCreateTime;
import cn.kawins.mybatis.interceptor.InsertAutoFilling;
import cn.kawins.mybatis.interceptor.UpdateAutoFilling;
import cn.kawins.mybatis.util.SnowflakeId;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModelProperty;
import tk.mybatis.mapper.annotation.KeySql;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
import java.util.List;
import lombok.*;

/**
 * 节点树信息，卫星列表结构以及卫星节点结构
 *
 * @author Nie
 * @version V1.0
 * @date 2023/8/14 11:25
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "health_xw.node_tree_info")
@EqualsAndHashCode(callSuper = true)
public class NodeTreeInfo extends BaseModel<Long> {
    @Id
    @ApiModelProperty(value = "主键")
    @Column(name = "id")
    @KeySql(genId = SnowflakeId.class)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    @ApiModelProperty(value = "卫星id", required = true)
    @Column(name = "satellite_id")
    private Long satelliteId;

    @ApiModelProperty(value = "分系统id")
    @Column(name = "system_id")
    private Long systemId;

    @ApiModelProperty(value = "上级节点id，最顶级节点的上级id为0L", required = true)
    @Column(name = "parent_id")
    private Long parentId;

    @ApiModelProperty(value = "节点名称", required = true)
    @Column(name = "node_name")
    private String nodeName;

    @ApiModelProperty(value = "节点code", required = true)
    @Column(name = "node_code")
    private String nodeCode;

    @ApiModelProperty(value = "节点级别")
    @Column(name = "level")
    private Integer level;

    /**
     * 综合评分
     */
    @ApiModelProperty(value = "综合评分")
    @Column(name = "overall_score")
    private Integer overallScore;

    /**
     * 健康状态
     */
    @ApiModelProperty(value = "健康状态")
    @Column(name = "health_status")
    private String healthStatus;

    /**
     * 健康状态
     */
    @ApiModelProperty(value = "卫星入轨时间（只有卫星节点有）")
    @Column(name = "injecting_time")
    private Date injectingTime;

    /**
     * 节点颜色
     */
    @ApiModelProperty(value = "节点颜色")
    @Column(name = "color")
    private String color;

    /**
     * 图片id
     */
    @ApiModelProperty(value = "图片id")
    @Column(name = "icon_id")
    private String iconId;


    @Transient
    private String filepath;

    /**
     * 创建时间
     */
    @Column(name = "created_time")
    @InsertAutoFilling(value = FillingCreateTime.class)
    @ApiModelProperty(value = "创建时间", accessMode = ApiModelProperty.AccessMode.READ_ONLY, example = "2010-01-01 00:00:00")
    private Date createdTime;
    /**
     * 更新时间
     */
    @Column(name = "updated_time")
    @UpdateAutoFilling(value = FillingCreateTime.class)
    @ApiModelProperty(value = "最后更新时间", accessMode = ApiModelProperty.AccessMode.READ_ONLY, example = "2010-01-01 00:00:00")
    private Date updatedTime;

    /**
     * 节点参数
     */
    @Transient
    @ApiModelProperty(value = "子节点", hidden = true)
    private List<NodeParamInfo> nodeParamInfoList;

    @Override
    public Long idValue() {
        return id;
    }
}
